package com.shijiwei.lifthelper.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.shijiwei.lifthelper.R;

import org.xutils.view.annotation.ViewInject;
import org.xutils.x;

import java.util.List;

/**
 * Created by sjw on 2015/12/16.
 */
public class WeatherAddCityAdapter extends AppBaseAdapter {
    private List<String> list;
    public WeatherAddCityAdapter(List<String> list, Context context) {
        super(list, context);
        this.list = list;
    }

    @Override
    public View getItemView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder = null;
        if (convertView == null){
            convertView = inflater.inflate(R.layout.item_listview_addcity,null);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        }else {
            holder = (ViewHolder) convertView.getTag();
        }

        holder.tvCityName.setText(list.get(position));
        return convertView;
    }

    class ViewHolder{
        @ViewInject(R.id.tv_city)
        TextView tvCityName;

        public ViewHolder(View convertView){
            x.view().inject(this,convertView);
        }
    }
}
